package com.lxj.mybatisplus.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lxj.mybatisplus.common.CommonResult;
import com.lxj.mybatisplus.model.User;
import com.lxj.mybatisplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 后台用户表 前端控制器
 * </p>
 *
 * @author 李学江
 * @since 2020-12-16
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("/findAll")
    public CommonResult<IPage> findAll(@RequestBody User user){
        IPage<User> iPage = userService.findAll(user);
        return CommonResult.success(iPage);
    }
    @GetMapping("/add")
    public CommonResult<Integer> add(@RequestBody User user){
        return CommonResult.success(userService.add(user));
    }
}
